<%@page import="java.util.*"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="UTF-8"%>
<%@ page import="java.sql.*"%>
<%@ page import="org.json.simple.JSONObject"%>
<%@ page import="org.json.simple.JSONArray"%>
<%@ page import="java.net.URLEncoder"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>


<%-- <%

	request.setCharacterEncoding("utf-8");
	String[] getAndroidData={"",""};
	getAndroidData[0]=request.getParameter("hey");
	getAndroidData[1]=request.getParameter("really");
	
	//JSON형태로 출력, 원하는 값 출력
	JSONObject jsonMain=new JSONObject(); //객체
	JSONArray jArray=new JSONArray(); //배열
	JSONObject jObject=new JSONObject(); //JSON내용을 담을 객체
	
	jObject.put("hey", "성공했다!!!!!!!!!!!");
	jObject.put("really", getAndroidData[0]);
	
	jArray.add(0, jObject);
	
	jsonMain.put("dataSend", jArray);
	
	out.println(jsonMain);
	out.flush();

%> --%>

<%
	
	String email=request.getParameter("email");
	
	String url="jdbc:oracle:thin:@192.168.0.18:1521:orcl";
	String user="book";
	String password="book";
	String sql=null;
	
	Connection conn=null;
	Statement stmt=null;
	ResultSet rs=null;
	
	try{
		Class.forName("oracle.jdbc.driver.OracleDriver");
		//out.println("드라이버 로딩 성공");
		conn=DriverManager.getConnection(url, user, password);
		//out.println("접속 성공");
		stmt=conn.createStatement();
		
		sql="SELECT * FROM MEMBER";
		rs=stmt.executeQuery(sql);
		JSONObject jsonMain=new JSONObject();
		JSONArray arr=new JSONArray();
		
		while(rs.next())
		{
			
			String mcode=URLEncoder.encode(rs.getString("mcode"), "UTF-8");
			String mname=rs.getString("mname");
			
			JSONObject obj=new JSONObject();
			obj.put("mname", mname);
			obj.put("mcode", mcode);
			
			arr.add(obj);
			jsonMain.put("dataSend", arr);
		
		}
		
		out.println(jsonMain);
		
	}catch(Exception e){
		out.println("접속 실패");
		e.printStackTrace();
	}
	
%>
